/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Log4jLogFileOpenDialog.java
 *
 * Created on 8 Jun, 2010, 2:23:03 PM
 */

package com.gs.logviewer.mockup;

import java.awt.event.ActionListener;
import java.awt.event.KeyListener;
import java.beans.PropertyChangeListener;

/**
 *
 * @author sabuj.das
 */
public class Log4jLogFileOpenDialog extends javax.swing.JDialog implements ActionListener, KeyListener, PropertyChangeListener {

    /** Creates new form Log4jLogFileOpenDialog */
    public Log4jLogFileOpenDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        jLabel1 = new javax.swing.JLabel();
        fileNameTextField = new javax.swing.JTextField();
        browseButton = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel2 = new javax.swing.JLabel();
        patternTextField = new javax.swing.JTextField();
        cancelButton = new javax.swing.JButton();
        okButton = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(new java.awt.GridBagLayout());

        jLabel1.setText("Log File");
        jLabel1.setName("jLabel1"); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
        getContentPane().add(jLabel1, gridBagConstraints);

        fileNameTextField.setEditable(false);
        fileNameTextField.setName("fileNameTextField"); // NOI18N
        fileNameTextField.addPropertyChangeListener(this);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
        getContentPane().add(fileNameTextField, gridBagConstraints);

        browseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/folder_open.png"))); // NOI18N
        browseButton.setName("browseButton"); // NOI18N
        browseButton.addActionListener(this);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
        getContentPane().add(browseButton, gridBagConstraints);

        jSeparator1.setName("jSeparator1"); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
        getContentPane().add(jSeparator1, gridBagConstraints);

        jLabel2.setText("Conversion Pattern");
        jLabel2.setName("jLabel2"); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
        getContentPane().add(jLabel2, gridBagConstraints);

        patternTextField.setName("patternTextField"); // NOI18N
        patternTextField.addKeyListener(this);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
        getContentPane().add(patternTextField, gridBagConstraints);

        cancelButton.setText("Cancel");
        cancelButton.setName("cancelButton"); // NOI18N
        cancelButton.addActionListener(this);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
        getContentPane().add(cancelButton, gridBagConstraints);

        okButton.setText("Ok");
        okButton.setName("okButton"); // NOI18N
        okButton.addActionListener(this);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST;
        gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
        getContentPane().add(okButton, gridBagConstraints);

        jLabel3.setName("jLabel3"); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        getContentPane().add(jLabel3, gridBagConstraints);

        pack();
    }

    // Code for dispatching events from components to event handlers.

    public void actionPerformed(java.awt.event.ActionEvent evt) {
        if (evt.getSource() == browseButton) {
            Log4jLogFileOpenDialog.this.browseButtonActionPerformed(evt);
        }
        else if (evt.getSource() == cancelButton) {
            Log4jLogFileOpenDialog.this.cancelButtonActionPerformed(evt);
        }
        else if (evt.getSource() == okButton) {
            Log4jLogFileOpenDialog.this.okButtonActionPerformed(evt);
        }
    }

    public void keyPressed(java.awt.event.KeyEvent evt) {
        if (evt.getSource() == patternTextField) {
            Log4jLogFileOpenDialog.this.patternTextFieldKeyPressed(evt);
        }
    }

    public void keyReleased(java.awt.event.KeyEvent evt) {
        if (evt.getSource() == patternTextField) {
            Log4jLogFileOpenDialog.this.patternTextFieldKeyReleased(evt);
        }
    }

    public void keyTyped(java.awt.event.KeyEvent evt) {
        if (evt.getSource() == patternTextField) {
            Log4jLogFileOpenDialog.this.patternTextFieldKeyTyped(evt);
        }
    }

    public void propertyChange(java.beans.PropertyChangeEvent evt) {
        if (evt.getSource() == fileNameTextField) {
            Log4jLogFileOpenDialog.this.fileNameTextFieldPropertyChange(evt);
        }
    }// </editor-fold>//GEN-END:initComponents

	private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
		// TODO add your handling code here:
	}//GEN-LAST:event_browseButtonActionPerformed

	private void patternTextFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_patternTextFieldKeyPressed
		// TODO add your handling code here:
	}//GEN-LAST:event_patternTextFieldKeyPressed

	private void patternTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_patternTextFieldKeyReleased
		// TODO add your handling code here:
	}//GEN-LAST:event_patternTextFieldKeyReleased

	private void patternTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_patternTextFieldKeyTyped
		// TODO add your handling code here:
	}//GEN-LAST:event_patternTextFieldKeyTyped

	private void fileNameTextFieldPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_fileNameTextFieldPropertyChange
		// TODO add your handling code here:
	}//GEN-LAST:event_fileNameTextFieldPropertyChange

	private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
		// TODO add your handling code here:
	}//GEN-LAST:event_cancelButtonActionPerformed

	private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
		// TODO add your handling code here:
	}//GEN-LAST:event_okButtonActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Log4jLogFileOpenDialog dialog = new Log4jLogFileOpenDialog(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton browseButton;
    private javax.swing.JButton cancelButton;
    private javax.swing.JTextField fileNameTextField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JButton okButton;
    private javax.swing.JTextField patternTextField;
    // End of variables declaration//GEN-END:variables

}
